home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 2 / Apprentice-Release2.iso / Source Code / Mark Pilgrim / Devil's Cubes 1.0.1 / source / Devil’s Cubes ƒ / Cube code / cube win.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-10-30  |  1.5 KB  |  68 lines  |  [TEXT/KAHL]

  1. /**********************************************************************\
  2.  
  3. File:        cube win.c
  4.  
  5. Purpose:    This module handles checking for a solved puzzle; also,
  6.             informing the user that they've finally won.
  7.  
  8.  
  9. Devil’s Cubes -- a simple cubes puzzle
  10. Copyright (C) 1993 Mark Pilgrim
  11.  
  12. This program is free software; you can redistribute it and/or modify
  13. it under the terms of the GNU General Public License as published by
  14. the Free Software Foundation; either version 2 of the License, or
  15. (at your option) any later version.
  16.  
  17. This program is distributed in the hope that it will be useful,
  18. but WITHOUT ANY WARRANTY; without even the implied warranty of
  19. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  20. GNU General Public License for more details.
  21.  
  22. You should have received a copy of the GNU General Public License
  23. along with this program in a file named "GNU General Public License".
  24. If not, write to the Free Software Foundation, 675 Mass Ave,
  25. Cambridge, MA 02139, USA.
  26.  
  27. \**********************************************************************/
  28.  
  29. #include "cube win.h"
  30. #include "cube.h"
  31. #include "msg dialogs.h"
  32. #include "msg sounds.h"
  33.  
  34. Boolean CheckForWin(void)
  35. {
  36.     Boolean        sameColor;
  37.     int            i,j,k;
  38.     
  39.     i=0;
  40.     do
  41.     {
  42.         j=0;
  43.         do
  44.         {
  45.             k=j+1;
  46.             do
  47.             {
  48.                 sameColor=(Cube[j][i]==Cube[k][i]);
  49.                 k++;
  50.             }
  51.             while ((!sameColor) && (k<4));
  52.             j++;
  53.         }
  54.         while ((!sameColor) && (j<4));
  55.         i++;
  56.     }
  57.     while ((!sameColor) && (i<4));
  58.     
  59.     return !sameColor;
  60. }
  61.  
  62. void WinGame(void)
  63. {
  64.     DoSound(sound_wingame);
  65.     PositionDialog('ALRT', winAlert);
  66.     Alert(winAlert, 0L);
  67. }
  68.